<template>
  <a-layout-sider
    v-model:collapsed="collapsed"
    :trigger="null"
    collapsible
    theme="light"
    class="ui-sider-content"
  >
    <div class="trigger">
      <menu-unfold-outlined
        v-if="collapsed"
        @click="() => (collapsed = !collapsed)"
      />
      <menu-fold-outlined v-else @click="() => (collapsed = !collapsed)" />
    </div>
    <u-menu :dataSource="menuData"></u-menu>
  </a-layout-sider>
</template>

<script>
import { Layout } from "ant-design-vue";

import UICLI from "components/ui-cli";

import { menuData } from "assets/js/Tmp";

import { MenuUnfoldOutlined, MenuFoldOutlined } from "@ant-design/icons-vue";

import { getHasPermissionList } from '@/access/api/user/index'

export default {
  name: "UISider",
  components: {
    ALayoutSider: Layout.Sider,
    UMenu: UICLI.UMenu,
    MenuUnfoldOutlined,
    MenuFoldOutlined,
  },
  data() {
    return {
      collapsed: false,
      menuData,
    };
  },
  methods: {
    getHasPermissionList() {
      getHasPermissionList()
        .then(res => {
          if(res) {
            this.menuData.groups = res
          }
        }) 
    }
  },
  created () {
    this.getHasPermissionList()
  }
};
</script>

<style lang="less" scoped>
.trigger {
  text-align: center;
  height: 48px;
  line-height: 48px;
  font-size: 18px;
  border-bottom: 1px solid #e8e8e8;
}
</style>